function [layer_one,motivations,oos]=SIV_layer_one(session,flag)


if flag==1
    a=load(['./data/house-',num2str(session)]);
else
    a=load(['./data/senate-',num2str(session)]);
end
for j=1:10;
    pc=a.partycode;pc(a.missed)=[];
    clear clp
    b=load(['./holdout samples/house-',num2str(session),'-holdout-',num2str(j),'.mat']);
    pc(b.missed)=[];
    lst=unique(pc);
    if numel(lst)>1
        clear nums
        for i1=1:numel(lst)
            nums(i1)=numel(find(pc==lst(i1)));
        end
        [~,idx]=sort(nums,'descend');
        
        
        clp(pc==lst(idx(1)))=1;
        clp(pc==lst(idx(2)))=2;
        i1=intersect(find(pc~=lst(idx(1))),find(pc~=lst(idx(2))));
        if numel(i1)>0
            P=makeperc(a.votes_no_holdout');
            tmp=P(pc==lst(idx(1)),i1);tmp1=P(pc==lst(idx(2)),i1);
            t1=nanmean(tmp(:));t2=nanmean(tmp(:));
            if t1>t2
                clp(i1)=1;
            else
                clp(i1)=2;
            end
        end
    end
    
    [layer_one,R,motivations,~]=partition_representation(convert_votes(b.votesmh),clp);
    t1=layer_one;
    t1=sign(t1(b.hinds))-convert_votes(b.votes_no_holdout(b.hinds));
    oos(j)=numel(find(t1==0))/numel(b.hinds);
    if flag==1
        save(['./results/house-',num2str(session),'-holdout-',num2str(j),'-layer-one.mat'],'layer_one','R','motivations','oos');
    else
        save(['./results/senate-',num2str(session),'-holdout-',num2str(j),'-layer-one.mat'],'layer_one','R','motivations','oos');
    end
    
end
oos=mean(oos);
end